#include "TimeServer.hpp"
#include "EventHandlerUnknownConnection.hpp"
#include "cybertron/core/UtilTime.hpp"
#include "cybertron/core/Thread.hpp"
#include "TheApp.hpp"

TimeServer::TimeServer()
{
	UtilTime::millisecondsUpdate();
}

TimeServer::~TimeServer()
{
	// do nothing.
}

void TimeServer::run()
{
	mHotAreaManager.run();
}

void TimeServer::exit() {
	mHotAreaManager.setWantQuit();
}

bool TimeServer::initialize()
{
	return mHotAreaManager.initialize();
}

void TimeServer::setTimeStart() {
	mHotAreaManager.setTimeSyncRun();
}

void TimeServer::loadConfigFromAgent(Agent::WorkNodeRegisterRet* args) {
	mHotAreaManager.loadConfigFromAgent(args);
	return;
}
void TimeServer::onAccept(SocketBasePtr pRemoteSocket)
{
	if (pRemoteSocket == nullptr)
	{
		return;
	}

	std::shared_ptr<EventHandlerUnknownConnection> pHandler =
		std::make_shared<EventHandlerUnknownConnection>();
	pRemoteSocket->addHandler(pHandler);
}
